<% %>
 <span id='indicator-tab' style="float:right;margin-right:20%;display:none;">
    <%=image_tag"indicator.gif"%>
 </span>
 <%#render :partial=>'time_log_tab'%>
<table class="TimeTrack" width=100%>
 <tr class="th">
   <td width=10% colspan=2><%='Project name'.t%></td>
   <td width=5%><%='Username'.t%></td>
   <td width=5%><%='Hours'.t%></td>
   <td width=10%><%='Start - End'.t%></td>
   <td width=10%><%='Time type'.t%></td>
   <td width=30%><%='Work desc'.t%></td>
   <td width=5%><%='Admin'.t%></td>
 </tr>
 <%@time_logs.each do |time_log|%>
  <tr id='entry_<%=time_log.id.to_s%>'
	   <%=time_log.after_work_time == 1 ? " class=after_work_time" : ""%>
    onmouseover="$('entry_<%=time_log.id%>').style.backgroundColor='#FFFFCC'" onmouseout="if($('cb_<%=time_log.id.to_s%>').checked){$('entry_<%=time_log.id%>').style.backgroundColor='#FFFFCC'} else {$('entry_<%=time_log.id%>').style.backgroundColor='';}">

    <td width=1%><%=check_box_tag "id[]",time_log.id,false,{:id=>'cb_' + time_log.id.to_s, :onclick=>"if ($('cb_" + time_log.id.to_s + "').checked){$('entry_" + time_log.id.to_s + "').style.backgroundColor='#FFFFCC'}else{$('entry_" + time_log.id.to_s + "').style.backgroundColor=''}",:class=>'chk',:disabled=>(not(@cur_user.has_permission?("prj_#{time_log.project.id}_time_edit") or @cur_user.id == time_log.user.id))}%></td>

    <td><%= link_to time_log.project.name,project_path(time_log.project)%></td>
    <td><%= link_to time_log.user.name,person_path(time_log.user)%></td>
	<td class="hours"><%=sprintf('%0.2f',(time_log.end_at - time_log.start_at)/3600) %></td>
	<td class="start"><%=time_log.start_at.to_formatted_s(:start_time)%> - <%=time_log.end_at.to_formatted_s(:end_time)%></td>
	<td>
	   <%=time_log.after_work_time == 1 ? "after work time".t : "work time".t%>
	</td>
    <td class='desc'>
	 <%if not time_log.activity_type.nil?%>
	   <%="[" + time_log.activity_type.name + "]"%>
	 <%end%>

	  <%if time_log.todo and time_log.todo_item%>
	  <%=link_to image_tag("i.gif",:border=>0),"#",:title=>"<b>" + "Todo".t + "</b>:" + time_log.todo.name + " <b>" + "Todo Items".t + "</b>:" +  time_log.todo_item.name,:alt=>"Todo".t + ":" + time_log.todo.name + " " + "TodoItem".t + ":" +  time_log.todo_item.name%>
	  <%end%>

	 <%if (desc_size = time_log.work_desc.size) > 1 %>
	 <span><%=link_to(image_tag("info.png",:border=>0) + (desc_size/3).to_s,"#",:onmouseover=>"Element.show('desc_" + time_log.id.to_s + "')",:onmouseout=>"Element.hide('desc_" + time_log.id.to_s + "')")%></span>
	 <div id=desc_<%=time_log.id%> style="display:none">
	    <%=time_log.work_desc%>
	 </div>
	 <%end%>
	 </td>
    <td class="action">
	<%if time_log.confirmed == 1%>
	  <%=link_to image_tag("i.gif",:border=>0),"#",:title=>"Confirmed by".t + ":" + time_log.confirmed_user.name + "<br/>" + "Confirmed at".t + ":" + time_log.confirmed_at.strftime(LONGDATE) if time_log.confirmed_user%>
	<%=image_tag "finish.gif"%>
	<%else%>
          <%if @cur_user.has_permission?("prj_#{time_log.project.id}_time_edit") or @cur_user.id == time_log.user.id%>
	  <%= link_to 'Edit'.t, edit_project_time_log_path(@project,time_log) %>
          <%=link_to_remote image_tag("trash.gif",:border=>0), 
		:loading => visual_effect(:highlight, "entry_#{time_log.id}", :duration =>1.5),
	        :url=>{:action => 'destroy', :id => time_log.id,:controller=>'time_logs'},:method=>'delete',
		:confirm => 'Are you sure?'.t
           %>
          <%end%>
	  <span id='indicator_<%=time_log.id%>' style="display:none">
	  <%=image_tag 'indicator.gif'%>
	  </span>
	<%end%>
	</td>
  </tr>
  <%end%>
 <%if @time_log_pages%>
 <tr>
<td colspan=6>
<%=hidden_field_tag "project_id",@project.id%>
<%=hidden_field_tag "submit",""%>
  <input type=button value='<%="Check All".t%>' onclick="togglePeople('chk')">
  <%if @cur_user.have_power?(@project)%>
  <input type=submit value='<%="Confirm".t%>' onclick="$('submit').value='confirm'">
  <input type=submit value='<%="Unconfirm".t%>' onclick="$('submit').value='unconfirm'">
  <%end%>
  <input type=submit value='<%="Delete".t%>' onclick="$('submit').value='delete';if (confirm('Are you sure?')) { submit(); };return false;">
  <%#link_to "Export".t + image_tag("icon/xls16.png",:border=>0),export_project_time_logs_path(@project.id)%> 
</td> 
 <td colspan=3 class='page' style="padding-top:10px;vertical-align:top">
  <%= link_to '<<', :page=>@time_log_pages.current.previous,:action=>'index',:controller=>'time_logs' if @time_log_pages.current.previous %>
  <%=pagination_links @time_log_pages,:params=>{:action=>'index',:controller=>'time_logs'}%>
  <%= link_to '>>',:page=>@time_log_pages.current.next,:action=>'index',:controller=>'time_logs' if @time_log_pages.current.next %> 
 </td></tr>
 <%end%>
 <%=render :partial => "time_log_foot"%>
</table>
